package com.gome.ocean.service.yugong.impl;

import java.util.List;

import org.apache.ibatis.session.RowBounds;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.github.pagehelper.Page;
import com.gome.ocean.dao.model.yugong.YgManagerBO;
import com.gome.ocean.dao.yugong.YgManagerDAO;
import com.gome.ocean.service.yugong.YgManagerService;

@Service
@Transactional("transactionManager")
public class YgManagerServiceImpl implements YgManagerService {

    @Autowired
    private YgManagerDAO ygManagerDAO;

    @Override
    public boolean insertYgManagerBO(YgManagerBO ygManager) {
        return ygManagerDAO.saveYgManagerBO(ygManager) == 1;
    }

    @Override
    public boolean removeYgManagerBOById(Long id) {
        return ygManagerDAO.deleteYgManagerBOById(id) == 1;
    }

    @Override
    public boolean updateYgManagerBO(YgManagerBO ygManager) {
        return ygManagerDAO.updateYgManagerBOById(ygManager) > 0;
    }

    @Override
    public YgManagerBO findYgManagerBOById(Long id) {
        return ygManagerDAO.findYgManagerBOById(id);
    }

    @Override
    public List<YgManagerBO> findUnoccupiedManagers() {
        return ygManagerDAO.findUnoccupiedManagers();
    }

    @Override
    public Page<YgManagerBO> findAllYgManagerBOsByProjectNames(List<String> projects, Integer pageNum,
                                                               Integer pageSize) {

        return ygManagerDAO.findAllManageByProject(projects, new RowBounds(pageNum, pageSize));
    }

    @Override
    public boolean enabledManager(Long id) {
        return ygManagerDAO.enabledManager(id) > 0;
    }

    @Override
    public boolean disableManager(Long id) {
        return ygManagerDAO.disableManager(id) > 0;
    }

    @Override
    public Page<YgManagerBO> findAllYgManager(Integer pageNum, Integer pageSize) {

        return ygManagerDAO.findAllYgManagerBOs(new RowBounds(pageNum, pageSize));
    }

}
